home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
tvdmx.exe
/
SAMPLES.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-07-16
|
25KB
|
820 lines
{■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■}
{ }
{ SAMPLES --Multi-window sample demo program }
{ tvDMX --data editing project (ver 1.5) }
{ }
{ Copyright (c) 1992 Randolph Beck }
{ P.O. Box 56-0487 }
{ Orlando, FL 32856 }
{ CIS: 72361,753 }
{ }
{■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■}
Program SAMPLES;
{ This program was written to demonstrate various data structures. You can
examine the field templates and copy some portions into WORKSHOP.PAS for
your own experiments.
The design of some of these record structures may seem pointless since
they are intended only to demonstrate the interface mechanism.
The "Account" window is the simplest example here. It's somewhat bland,
but most programmers will only require simple data structures like this.
The "Payroll" window is a larger data window. It demonstrates the 'Z'
template code, which forces the display of leading zeroes in that field.
Its last three fields are marked as READ-ONLY (with the ^R code). These
are entered automatically by the virtual methods in object TDmxPayroll,
which overrides TDmxEditor.
The "Busy" window uses a more complex template string. Note the heavy use
of control codes, and that the last field in the main window is Read-Only.
One of the integer fields is marked as a "skip" field (that means that the
cursor will not land on it).
The DateTime type is used here, with fldDATETIME, fldDATE, and fldTIME
constants --as defined in the DMXGIZMA unit. Its Year, Month and Day are
swapped by codes in the fldDATETIME and fldDATE string to place it in its
more familiar Month-Day-Year order.
Two other views are available from the menu: "Hex" is a tvDMX-driven
hex-byte editor using the same data as Busy window; and "Dialog" is a
dialog box that uses tvDMX descendants for individual field input, using
the data in the current window at the current record. A dialog window
may also be actuated by double-clicking a record with a mouse.
The data in most windows can be reported to file SAMPLES.OUT, using the
objects in unit tvDMXREP.PAS.
(See file TVDMXHEX.PAS for the code used in the hexadecimal byte editor.)
}
{$V-,X+ }
uses
Dos, { required to define DateTime type }
Objects, Drivers, Views, Menus, Dialogs, App, MsgBox,
RSet, DmxGizma, tvDMX, StdDMX, tvDmxHex, tvDmxRep, tvGizma;
const
ReportName = 'SAMPLES.OUT';
cmHasDialog = 103;
cmAccounts = 111;
cmPayroll = 112;
cmBusyWin = 113;
cmHexWin = 114;
cmDialog = 115;
cmRecDialog = 116;
cmReport = 117;
cmNoCmd = 1000;
hcMenus = 1000;
hcDeskTop = 1100;
hcAccounts = 1100;
hcPayroll = 1200;
hcBusyWin = 1300;
hcHexWin = 1400;
hcDialogs = 4000;
{ Data presentation template for the "Accounts" window.
The data structure is declared as "TAccount" in the TYPE section.
}
AccountLabel : string =
' Transaction Debit Credit [?] ';
AccountInfo : string =
' SSSSSSSSSSSSSSSS| rrr,rrr.rr | rrr,rrr.rr | [x] ';
{ Data presentation template for the "Payroll" window.
The data structure is declared as "TPayroll" in the TYPE section.
The last three fields are marked READ-ONLY, and are automatically
entered by the virtual methods in object TDmxPayroll.
}
_PayrollLabel = ' Employee ID Earnings FICA FITW SITW ';
_PayrollInfo = ' ssssssssssssssssssssss| ZZW ║ $rr,rrr.rr | $r,rrr.rr '^R'| $r,rrr.rr '^R'| $r,rrr.rr '^R;
PayrollLabel : string [length (_PayrollLabel)] = _PayrollLabel;
PayrollInfo : string [length (_PayrollInfo)] = _PayrollInfo;
{ This next screen will be a bit busy, but I wanted to implement many
of the special options. I thought it might be easier to decipher
all this by separating the field-strings into one field per line.
Each line (except the first) begins with a field delimiter.
The data structure is declared as "TBusyData" in the TYPE section.
}
_BusyLabel =
' Name SSN Balance Start Date Time <A> [B] Pointer Value RO ';
_BusyInfo = 'B' + ^H { hidden byte field }
+ #0' ssssssssssssssssssssss' { Name field }
+ '| ###-##-#### ' { string of numerics only }
+ '|r,rrr,rrr ' { positive or negative }
{ DateTime type: }
+ '|' + fldDATE { untyped constants }
+ #0 + fldTIME { defined in DMXGIZMA.PAS }
+ '|iii ' + ^Z^R^S { showzeroes/readonly/skip }
+ '\iii ' { normal integer }
+ '| HHHH:HHHH ' { hex longint value }
+ '|RRR,RRR.RRR ' { positive values only }
+ '| hh ' + ^Z^R; { showzeroes/readonly field }
BusyInfo : string [length (_BusyInfo)] = _BusyInfo;
BusyLabel : string [length (_BusyLabel)] = _BusyLabel;
MaxRecordNum = 29;
type
PAccount = ^TAccount;
PPayroll = ^TPayroll;
PBusyData = ^TBusyData;
TAccount = RECORD
Account : string [16];
Debit : real;
Credit : real;
Status : boolean;
end;
TPayroll = RECORD
Employee : string [22];
ID : word;
Earnings : real;
FICA : real; { READ-ONLY }
FITW : real; { READ-ONLY }
SITW : real; { READ-ONLY }
end;
TBusyData = RECORD
Marker : byte; { HIDDEN field }
Name : string [22];
SSN : string [9];
realfield1 : real;
DT : datetime;
intfield0 : integer; { READ-ONLY }
intfield1 : integer;
ptrfield : pointer;
realfield2 : real;
hextwo : byte; { READ-ONLY }
end;
PDmxEditTbl = ^TDmxEditTbl;
PDmxEditTblWin = ^TDmxEditTblWin;
TDmxEditTbl = OBJECT (TDmxEditor)
procedure HandleEvent (var Event : TEvent); VIRTUAL;
end;
TDmxEditTblWin = OBJECT (TDmxWindow)
procedure InitDMX (ATemplate : string; var AData;
ALabels, ARecInd : PDmxLink;
BSize : longint); VIRTUAL;
end;
PDmxPayroll = ^TDmxPayroll;
PDmxPayrollWin = ^TDmxPayrollWin;
TDmxPayroll = OBJECT (TDmxEditTbl)
procedure EvaluateField; VIRTUAL;
procedure ZeroizeField (Whole :boolean; Field :pDMXfieldrec); VIRTUAL;
procedure RecalcRecord;
end;
TDmxPayrollWin = OBJECT (TDmxWindow)
procedure InitDMX (ATemplate : string; var AData;
ALabels, ARecInd : PDmxLink;
BSize : longint); VIRTUAL;
end;
PMyStatusLine = ^TMyStatusLine;
TMyStatusLine = OBJECT (TStatusLine)
function Hint (AHelpCtx : word) : string; VIRTUAL;
end;
TAppN = OBJECT (TAppA)
end;
TMyApp = OBJECT (TAppN)
constructor Init;
procedure Idle; VIRTUAL;
procedure HandleEvent (var Event : TEvent); VIRTUAL;
procedure InitMenuBar; VIRTUAL;
procedure InitStatusLine; VIRTUAL;
procedure AccountWindow;
procedure PayrollWindow;
procedure BusyWindow;
procedure HexWindow;
procedure AccountDialog (P : PDmxEditTbl);
procedure PayrollDialog (P : PDmxPayroll);
procedure BusyDialog (P : PDmxEditTbl);
end;
var
Accounts : array [0..49] of TAccount;
Payroll : array [0..49] of TPayroll;
BusyData : array [0..MaxRecordNum] of TBusyData;
procedure InitializeData; forward; { for the sample data }
{ ══ TMyStatusLine ═════════════════════════════════════════════════════ }
function TMyStatusLine.Hint (AHelpCtx : word) : string;
begin
Case AHelpCtx of
hcDragging: Hint := #24#25#26#27' Move Shift-'#24#25#26#27' Resize '#17#196#217' Done Esc Cancel';
else Hint := '';
end;
end;
{ ══ TDmxEditT